"""
Case Type   : 资源池化
Case Name   : gs_collector收集信息,只指定开始时间
Create At   : 2024.01
Owner       : chen
Description :
    1、只指定开始时间: gs_collector --begin-time="{date}"
Expect      :
    1、合理报错
"""

import os
import unittest
import datetime
from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger
from yat.test import Node
from yat.test import macro


class SharedStorage(unittest.TestCase):

    def setUp(self):
        self.log = Logger()
        self.log.info(f'-----{os.path.basename(__file__)} start-----')
        self.constant = Constant()
        self.pri_node = Node('PrimaryDbUser')

    def test_shared_storage(self):
        text = '-----step1: 只指定开始时间: gs_collector --begin-time="date"' \
            ' expect: 合理报错-----'
        self.log.info(text)
        start = datetime.datetime.now().strftime('%Y%m%d %H:%M')
        cmd = f'source {macro.DB_ENV_PATH};' \
                 f'gs_collector --begin-time="{start}"'
        self.log.info(cmd)
        res = self.pri_node.sh(cmd).result()
        self.log.info(res)
        self.assertIn(self.constant.GS_TOOLS_ERROR_MSG1, res)

    def tearDown(self):
        self.log.info(f'-----{os.path.basename(__file__)} end-----')